﻿using SHKF.B2C.MeiTuanPeiSong.Model.Dto.Order;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace SHKF.B2C.Mannage.AdminUI.Network
{
    public class HttpClientMtps : HttpClient
    {
        public HttpClientMtps()
        {
            string uri = ConfigurationManager.AppSettings["urlMtps"];
            base.BaseAddress = new Uri(uri);
        }
        public async Task<OrderListDto> QueryOrder(string shopID, string orderID, int status, DateTime startDate, DateTime endDate)
        {
            string url = base.BaseAddress.OriginalString + "/order/list?";
            url += $"shopID=" + shopID;
            url += $"&orderID=" + orderID;
            url += $"&startDate=" + startDate.ToString("yyyy-MM-dd HH:mm:ss");
            url += $"&endDate=" + endDate.ToString("yyyy-MM-dd HH:mm:ss");

            OrderListDto dto = null;
            HttpResponseMessage httpResponseMessage = await base.GetAsync(url);
            if (httpResponseMessage.IsSuccessStatusCode)
            {
                dto = await httpResponseMessage.Content.ReadAsAsync<OrderListDto>();
            }
            else
            {
                dto = new OrderListDto();
                dto.SetError(httpResponseMessage);
            }
            return dto;
        }
    }
}
